<template>

</template>

<script>
export default {
  methods: {
    showMessage() {
      const h = this.$createElement
      this.$msgbox({
        title: '部门名称',
        message: h('el-tree', {
          props: {
            data: orgData
          },
          attrs: {
            'show-checkbox': true,
            'check-strictly': true,
            'node-key': 'id'
          },
          ref: 'departmentTree'
        }),
        showCancelButton: true,
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        beforeClose: (action, instance, done) => {
          instance.confirmButtonLoading = true
          instance.confirmButtonText = '执行中...'
          if (action === 'confirm') {
            const checkedNodes = this.$refs.departmentTree.getCheckedNodes();
            if (checkedNodes.length) {
              this.$emit('departmentChange', checkedNodes)
            }
          }
          instance.confirmButtonLoading = false
          this.$emit('close')
          done()
        }
      }).catch(e => {
        this.$emit('close')
      })
    },
    setCheckedKeys (ids) {
      if (!this.$refs.departmentTree) return
      this.$refs.departmentTree.setCheckedKeys(ids)
    }
  }
};
</script>


<style scoped>
</style>
